package com.zline.foodraise.view;

import android.content.Context;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.zline.foodraise.R;
import com.zline.foodraise.constant.Constant;
import com.zline.foodraise.entity.CustomerUserBean;
import com.zline.foodraise.listener.RecyclerItemClicked;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by heshantao on 15/7/6.
 * 赞列表
 */
@EViewGroup(R.layout.dynamic_item_support_item)
public class DynamicItemSupportItem extends RelativeLayout {
    private static final String LOG_TAG = DynamicItemSupportItem.class.getSimpleName();
    @ViewById(R.id.dynamic_item_comment_item_circleIv)
    CircleImageView person_civ;
    @ViewById(R.id.dynamic_item_comment_support_vip_iv)
    ImageView vip_iv;
    ImageLoader imageLoader;
    RecyclerItemClicked itemClicked;
    int position;
    int parentPosition = -1;
    String person_icon_url;
    int authenticateType;

    public DynamicItemSupportItem(Context context) {
        super(context);
    }

    public void bind(CustomerUserBean userBean, int position,
                     int parentPosition,DisplayImageOptions options) {
        this.parentPosition = parentPosition;
        this.position = position;
        imageLoader = ImageLoader.getInstance();
        authenticateType = userBean.getIdentificateType();
        person_icon_url = userBean.getAvatarPicUrl();
        imageLoader.displayImage(person_icon_url, person_civ, options);
        if (authenticateType == 1) {
            vip_iv.setVisibility(VISIBLE);
        } else {
            vip_iv.setVisibility(GONE);
        }


    }

    @Click(R.id.dynamic_item_comment_item_circleIv)
    void onClick() {
        if (parentPosition < 0) {
            itemClicked.onRecyclerItemClicked(Constant.DYNAMIC_SUPPORT_FLAG, position);
        } else {
            itemClicked.onRecyclerItemClicked(Constant.DYNAMIC_SUPPORT_FLAG, parentPosition);
        }
    }

    public void setRecyclerItemClick(RecyclerItemClicked clicked) {
        this.itemClicked = clicked;

    }
}
